package com.xncoding.rocketmq;

import com.alibaba.fastjson.JSON;
import com.xncoding.rocketmq.entity.User;
import com.xncoding.rocketmq.producer.callback.AsyncSendCallback;
import com.xncoding.rocketmq.utils.RocketMqHelper;
import org.apache.rocketmq.client.producer.SendCallback;
import org.apache.rocketmq.client.producer.SendResult;
import org.apache.rocketmq.spring.core.RocketMQTemplate;
import org.springframework.test.context.testng.AbstractTestNGSpringContextTests;
import org.testng.annotations.Test;
//import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.messaging.support.MessageBuilder;

//@RunWith(SpringRunner.class)
@SpringBootTest
public class poutest extends AbstractTestNGSpringContextTests {
    @Autowired
    RocketMqHelper rocketMqHelper;
    @Autowired
    private RocketMQTemplate rocketMQTemplate;
    @Test
    public void testProducter() {
        System.out.println("*************************");
        User person = new User();
        person.setName("heyuhua");
        person.setAge(25);
        rocketMqHelper.asyncSend("USER_ADD", MessageBuilder.withPayload(person).build());
        rocketMQTemplate.syncSend("USER_ADD", MessageBuilder.withPayload(person).build());
    }

}
